Imports Clo = Enhancements.Core.Logging
Imports Fun = Enhancements.Basic.Expressions.Functions
Imports Gen = System.Collections.Generic
Imports Glo = System.Globalization
Imports Ref = System.Reflection
Imports Sys = System
Imports Val = Enhancements.Basic.Expressions.Values

Namespace Enhancements.Basic.Expressions
    Partial Class Compiler
        <Serializable(), DebuggerStepThrough()> _
            Private NotInheritable Class __FunctionsAnalysis

            Private Sub New()
            End Sub

            ''' <exception cref="IsNullException"> </exception>
            ''' <exception cref="IsListFilledNotException"> </exception>
            ''' <exception cref="IsInRangeNotException"> </exception>
            ''' <exception cref="IdentifiersAreRepeatedException"> </exception>
            ''' <exception cref="CompilerFunctionsWithSameOperatorHaveEqualSignaturesException"> </exception>
            Friend Shared Sub AssertAreValid(ByVal _compiler As Compiler, ByVal _functions() As Fun.Function)
                _compiler.IsNullNot("_compiler", True)
                _functions.IsListFilled("_functions", True)
                _functions.Length.IsInRange("_functions.Length", 1, Sys.Int32.MaxValue, True)
                _functions.IsListWithUniqueValues("_functions", True)
                ___Identifiers.AssertAreRepeatedNot(_compiler.___FunctionsSortedGet(_functions).Keys.ToArray(), True)
                For _counter1 As Sys.Int32 = 0 To _functions.Length - 1
                    For _counter2 As Sys.Int32 = _counter1 + 1 To _functions.Length - 1
                        If _functions(_counter1).Operator.IsNullNot("_functions(_counter1).Operator", False) AndAlso _functions(_counter2).Operator.IsNullNot("_functions(_counter2).Operator", False) Then
                            If _functions(_counter1).Operator.Operator.Is("_functions(_counter1).Operator.Operator", _functions(_counter2).Operator.Operator, "_functions(_counter2).Operator.Operator", False) Then
                                For _counter3 As Sys.Int32 = 0 To _functions(_counter1).Signatures.Length - 1
                                    For _counter4 As Sys.Int32 = _counter3 + 1 To _functions(_counter2).Signatures.Length - 1
                                        If _functions(_counter1).Signatures(_counter3).Equals(_functions(_counter2).Signatures(_counter4)) Then
                                            CompilerFunctionsWithSameOperatorHaveEqualSignaturesException.___Throw(_functions(_counter1), _functions(_counter1).Signatures(_counter3), _functions(_counter2), _functions(_counter2).Signatures(_counter4))
                                        End If
                                    Next _counter4
                                Next _counter3
                            End If
                        End If
                    Next _counter2
                Next _counter1
            End Sub

        End Class
    End Class
End Namespace
